package StudyCode.summary.mycollection;

import java.util.ArrayDeque;
import java.util.Iterator;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class DequeCreateAndPrintTheContentsOfAnArrayDeque {
	public static void main(String[] args) {
		ArrayDeque<String> aDeque = new ArrayDeque<>();

		aDeque.addFirst("tea");
		aDeque.addFirst("milk");
		aDeque.addFirst("coffee");
		aDeque.addLast("sugar");

		for (Iterator itr = aDeque.iterator(); itr.hasNext(); ) {
			System.out.println(itr.next());
		}
		System.out.println();

		aDeque.addFirst("juice");
		aDeque.addLast("honey");

		System.out.println("第一个元素: " + aDeque.getFirst());
		System.out.println("最后一个元素 : " + aDeque.getLast());

		System.out.println("移除第一个元素:" + aDeque.removeFirst());
		System.out.println("移除最后一个元素:" + aDeque.removeLast());

		System.out.println("%n弹出元素 : " + aDeque.pop());
		System.out.println("Array Deque 大小: %n" + aDeque.size());

	}
}
